﻿using NFine.Application.BusinessManage;
using NFine.Code;
using NFine.Domain.Entity.BusinessManage;
using System.Web.Mvc;

namespace NFine.Web.Areas.BusinessManage.Controllers
{
    public class D_IndentController : ControllerBase
    {
        //
        // GET: /BusinessManage/D_Indent/

        private D_IndentApp indentApp = new D_IndentApp();

        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetGridJson(Pagination pagination, string keyword)
        {
            var data = new
            {
                rows = indentApp.GetList(pagination, keyword),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetIndentGridJson(Pagination pagination, string keyword)
        {
            var data = new
            {
                rows = indentApp.GetIndentGridJson(pagination, keyword),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
        //[HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GeMemtGridJson(Pagination pagination, string pData)
        {

            var data = new
            {
                rows = indentApp.GetMemList(pagination, pData),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }

        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetFormJson(string keyValue)
        {
            var data = indentApp.GetForm(keyValue);
            return Content(data.ToJson());
        }

        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetMemberIndentFormJson(string keyValue)
        {
            var data = indentApp.GetMemberIndentFormJson(keyValue);
            return Content(data.ToJson());
        }
        [HttpPost]
        [HandlerAjaxOnly]
        [ValidateAntiForgeryToken]
        public ActionResult SubmitForm(D_IndentEntity areaEntity, string keyValue)
        {
            indentApp.SubmitForm(areaEntity, keyValue);
            return Success("操作成功。");
        }
        [HttpPost]
        [HandlerAjaxOnly]
        [ValidateAntiForgeryToken]
        public ActionResult CheckForm(D_IndentEntity areaEntity, string keyValue)
        {
            indentApp.CheckForm(areaEntity, keyValue);
            return Success("操作成功。");
        }
        [HttpPost]
        [HandlerAjaxOnly]
        [HandlerAuthorize]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteForm(string keyValue)
        {
            indentApp.DeleteForm(keyValue);
            return Success("删除成功。");
        }
        [HttpGet]
        public ActionResult IndentList()
        {
            return View();
        }
    }
}
